<?
class Event extends Module
{
	function Event($row)
	{
		Module::Module($row);
		
		if(User::is_admin())
		{
			$cmd	=	Url::get('cmd');
			
			switch($cmd)
			{		
				case 'del':
					if(User::is_root())
					{
						$e_id	=	Url::get('id');
						
						if($e_id)
						{
							$event_product = DB::select('event_product',"id=$e_id");
						
							if($event_product && $event_product['status'] != 3 && $event_product['status'] != 4)
							{
								DB::update('event_product',array(
																	'status' 	=> 4,
																	'time_del' 	=> TIME_NOW,
																	'user_del' 	=> User::user_name(),
																	),"id=$e_id");	
							}
						}
					}
					
					Url::redirect_current();
					break;
				case 'active':
					$e_id	=	Url::get('id');
					if($e_id)
					{
						$event_product = DB::select('event_product',"id=$e_id");
						
						if($event_product && $event_product['status'] == 1)
						{
							DB::update('event_product',array(
																	'status' 	=> 2,
																	'time_m' 	=> TIME_NOW,
																	'user_m' 	=> User::user_name(),
																	),"id=$e_id");	
						}
					}
					Url::redirect_current();
					break;
				case 'disable':
					$e_id	=	Url::get('id');
					if($e_id)
					{
						$event_product = DB::select('event_product',"id=$e_id");
						
						if($event_product && $event_product['status'] == 2)
						{
							DB::update('event_product',array(
																	'status' 	=> 1,
																	'time_m' 	=> TIME_NOW,
																	'user_m' 	=> User::user_name(),
																	),"id=$e_id");	
						}
					}
					Url::redirect_current();
					break;
				case 'edit':
					require_once 'forms/EventEdit.php';
					$this->add_form(new EventEditForm());
					break;
				case 'add':
					require_once 'forms/EventAdd.php';
					$this->add_form(new EventAddForm());
					break;
				default: 
					require_once 'forms/EventProduct.php';
					$this->add_form(new EventProductForm());
					break;
			}
		}
		else
		{
			Url::access_denied();
		}
	}
}
?>